#!/bin/bash 
if [ "$1" = "" ];
    then
        echo -e "\033[0;31m 未输入操作名 \033[0m  \033[0;34m {start|stop|restart|status} \033[0m"
 	
 	exit 1
fi


cd ~/envpro
source ./jar_go.sh

declare -A site
site["reg"]="envpro-register"
site["gw"]="envpro-gateway"
site["auth"]="envpro-auth"
site["upms"]="envpro-upms-biz"
site["mp"]="envpro-mp-platform"
site["codegen"]="envpro-codegen"
site["app"]="envpro-app-server-biz"
site["oa"]="envpro-oa-platform"
site["pay"]="envpro-pay-platform"
site["jimu"]="envpro-jimu-platform"
site["seata"]="envpro-seata-server"
site["report"]="envpro-report-platform"
site["quartz"]="envpro-daemon-quartz"
site["xxjob"]="envpro-xxl-job-admin"
site["es"]="envpro-daemon-elastic-job"
site["sentinel"]="envpro-sentinel-dashboard"
site["monitor"]="envpro-monitor"

for key in ${!site[*]};do
    echo "${key} : ${site[$key]}"
done

# 定义指令数组  
#commands=("echo 'Hello, World!'" "ls -l" "pwd" "date")  
  
# 询问用户输入键值  
read -p "请输入要执行的指令的键值（以空格分隔）: " keys  
  
# 将输入的键值转换为数组  
IFS=' ' read -ra ADDR <<< "$keys"  
  
# 遍历用户输入的键值  
for key in "${ADDR[@]}"; do  
    # 检查键值是否在数组范围内  
    if (( key >= 0 && key < ${#site[@]} )); then  
        # 执行相应的指令  
	eval echo "================"${site[$key]}"================"  
        eval exec $1 ${site[$key]}
    else  
        echo "错误：键值 $key 不在有效范围内."  
    fi  
done  
  
# 脚本结束  
exit 0
